Compiling Assembly Manually [migrated]

Posted by John Smith on Super User See other posts from Super User or by John Smith
Published on 2012-10-11T20:32:56Z Indexed on 2012/10/11 21:39 UTC
Read the original article Hit count: 317

Filed under:
|

I am having trouble with translating a specific line in assembly to machine code for the Nios II. I have successfully compiled these lines:

START_TIMER = 0xF68C
r0 = 0x0
r8 = 0x8
label = 50000

addi r8, r8, %lo(label) - 01000 01000 1100001101010000 000100
subi r8, r8, 1 - 01000 01000 1111111111111111 000100
bne r8, r0, START_TIMER - 01000 00000 1111011010001100 011110

The line in question that I have trouble with is this one:

orhi r8, r0, %hiadj(label)

As explained in the handbook linked above, "%lo" means "Extract bits [15..0] of immed32" and "%hiadj" means "Extract bits [31..16] and adds bit 15 of immed32". However, 50000 in binary is 1100001101010000, and is therefore a 16 bit number. As far as I can see, it doesn't contain any bits between 16 and 31. I tried with 0000000000000001, but it's incorrect.

What am I doing wrong?

© Super User or respective owner

Related posts about compile

Related posts about assembly